package com.gopay.checkorder.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.checkorder.dao.AccountRoleDefDAO;
import com.gopay.checkorder.domain.AccountRoleDef;
import com.gopay.common.base.dao.impl.BaseDAOImpl;

/**
 * 会计分录DAO实现
 * 
 * @AccountRoleDefDAOImpl.java
 * @author yaobo
 * @2013-7-9 上午11:12:41 www.gopay.com.cn Inc.All rights reserved.
 */
@Repository(value = "accountRoleDefDAO")
public class AccountRoleDefDAOImpl extends BaseDAOImpl<AccountRoleDef, Integer> implements AccountRoleDefDAO {

    @Override
    public List<AccountRoleDef> getAccountRoleDefs(String gopayIntTxnCd, String payChannel, String orderFeePayer,
            String accountPoint) {
        String hql = "from AccountRoleDef where gopayIntTxnCd = :gopayIntTxnCd and payChannel = :payChannel and orderFeePayer = :orderFeePayer";

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("gopayIntTxnCd", gopayIntTxnCd);
        params.put("payChannel", payChannel);
        params.put("orderFeePayer", orderFeePayer);

        return this.findByHql(hql, params);
    }

    @Override
    public int getAccountRoleDefCount(String gopayIntTxnCd, String payChannel, String orderFeePayer, String accountPoint) {
        List<AccountRoleDef> list = getAccountRoleDefs(gopayIntTxnCd, payChannel, orderFeePayer, accountPoint);
        if (list == null || list.size() == 0) {
            return 0;
        }

        return list.size();
    }

}
